<!DOCTYPE html>
<html>
    <head>
        <title>吊装记录</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="Content-Language" content="zh-CN" />
        <meta http-equiv="Content-Script-Type" content="text/javascript" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
        <meta name="format-detection" content="telephone=no"/>
		<link rel="stylesheet" href="css/bootstrap.min.css">
		<link rel="stylesheet" type="text/css" href="css/index.css"/>
		<script src="js/jquery.min.js"></script>
		<script src="js/bootstrap.min.js"></script>	
		<style>
			.title_top{text-align: center;}
			.rq{padding: 0;}
			.rq a{color: #FFF;}
			.title{height:44px;line-height: 44px;border-bottom: 1px solid #ECECEC;}
			.record{background-color: #F1F5F8;}
			button:focus{-webkit-tap-highlight-color:transparent;}
			.start-pull-up{text-align: center;display:none;}
			.nodata{margin:0 auto;text-align:center;padding-top:50%;}
			.nodata img{width:50%;height:50%;}
		</style>
    </head>
	<body class="body_1">
		<div class="col-xs-12 title_top">
			<div class="col-xs-3 rq back">
				<a href="javascript:history.back(-1)">
					<div style="float: left;"><img src="images/icon_left.png"/></div>
					<div style="float: left;margin-top: 2px;">返回</div>
				</a>
			</div>
			<div class="col-xs-6">吊装记录</div>
			<div class="col-xs-3" style="padding-right: 0;">
				<div class="shaixuan">	
					<img src="images/icon_shaixuan.png"/> 
					<div class="cat">筛选</div> 
				</div>
			</div>
		</div>
		<div class="col-xs-12 list record" style="margin-top: 50px;">
			<div class="col-xs-5 title">塔机备案编号</div>
			<div class="col-xs-5 title">开始时间</div>
			<div class="col-xs-2 title">操作</div>
		</div>
		<div class="lists" id="refreshContainer">
			
		</div>
		<div class="start-pull-up"><img src='images/sx-icon.gif'> </div>
	</body>
</html>
<script src="js/mui.min.js"></script>
<script src="js/project.config.js"></script>
<script src="js/jquery.min.js"></script>
<script>
	var curPage = 1;
	var pageSize = 8;
	window.onload = function(){
		ajax_lists(curPage,pageSize,'down');
	}
	mui.init({
		pullRefresh : {
			container:"#refreshContainer",//下拉刷新容器标识，querySelector能定位的css选择器均可，比如：id、.class等
			down : {
				style:'circle',//必选，下拉刷新样式，目前支持原生5+ ‘circle’ 样式
				color:'#00A4FF', //可选，默认“#2BD009” 下拉刷新控件颜色
				height:'100px',//可选,默认50px.下拉刷新控件的高度,
				range:'100px', //可选 默认100px,控件可下拉拖拽的范围
				offset:'0px', //可选 默认0px,下拉刷新控件的起始位置
				callback :function(){ 
					curPage = 1;
					ajax_lists(curPage,pageSize,'down');
					mui('#refreshContainer').pullRefresh().endPulldown();
				}
			},
			up : {
				height:50,//可选.默认50.触发上拉加载拖动距离
				contentrefresh : "正在加载...",//可选，正在加载状态时，上拉加载控件上显示的标题内容
				contentnomore:'没有更多数据了',//可选，请求完毕若没有更多数据时显示的提醒内容；
				callback :function(){
					curPage++;
					$(".start-pull-up").show();
					ajax_lists(curPage,pageSize,'up'); 
					$(".start-pull-up").hide();
					mui('#refreshContainer').pullRefresh().endPullupToRefresh(false); 
				}
			}
		}
	});
	mui(".lists").on('tap','button',function(){
		var id = $(this).data('id');
		var starttime = $(this).data('starttime');
		var endtime = $(this).data('endtime');
		redirect('t_work_data.html',{
			towerID:id,
			starttime:starttime,
			endtime:endtime,
		});
		return false;
	});
	function ajax_lists(curPage,pageSize,type){
		 mui.plusReady(function () {
			var token = get_token();
			var params = get_ws();
			mui(".title_top").on("tap",".back",function(){
				mui.back();
			});
			mui(".title_top").on("tap",".cat",function(){
				redirect('t_cat.html',{
					towerID:params.towerID
				});
			});
			var data = {};
			data.api = 'tower-get-work-cycle';
			data.token = token;
			data.towerID = params.towerID;
			data.startTime = params.startTime;
			data.endTime = params.endTime;
			if(params.time){
				mui.ajax(project_cofnig.service_past_time, {
					async: false,
					dataType: 'json',
					data:{'type':params.time},
					success: function (ref) {
						data.startTime = ref.start_time;
						data.endTime = ref.end_time;
					}
				});
			}
			data.status = (params.status ? params.status:0);
			data.curPage = curPage;
			data.pageSize = pageSize;
			data.justCount = 0;
			mui.ajax(project_cofnig.service_url, {
				async: true,
				dataType: 'json',
				data: data,
				success: function (ref) {
					if(ref.data.recCount == 0 && curPage == 1 ){
						$(".lists").html("<div class='nodata'><img src='images/nodata.png'></div>");
						return false;
					}
					var _html = ''; 
					$.each(ref.data.records,function(i,v){
						//时间转换
						var start_time = '';
						var end_time = '';
						mui.ajax(project_cofnig.service_dec, {
							async: false,
							dataType: 'json',
							data: {start_time:v.startTime,end_time:v.endTime,format:'Y-m-d H:i:s'},
							success: function (ref) {
								start_time = ref.start_time;
								end_time = ref.end_time;
							}
						});
						_html += '<div class="col-xs-12 list_list record_record">';
						_html += '<div class="col-xs-5 title record_left" style="height:50px;" >';
						_html += '<p class="record_p_1" style="margin-top:-20px;" >'+v.recordNum+'</p>';
						_html += '<p class="record_p_2"style="margin-top:-35px;" >塔机状态：<span style="background-color:'+get_statusDesc_rgb(v.statusDesc)+';" >'+(v.statusDesc ? v.statusDesc : '正常')+'</span></p>';
						_html += '</div>';
						_html += '<div class="col-xs-5 title record_height" style="height:50px;" >'+start_time+'</div>';
						_html += '<div class="col-xs-2 title record_height" style="height:50px;">';
						_html += '<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal" data-id="'+v.towerID+'" data-starttime="'+v.startTime+'" data-endtime="'+v.endTime+'" >';
						_html += '查看</button>';
						_html += '</div>';
						_html += '</div>';
					});
					if(type == 'down' && curPage == 1){
						$(".lists").html(_html);
					}else{
						$(".lists").append(_html);
					}
					return false;
				}
			});		
		});
	}
</script>
		 
		 